package patrol.mobile.com.mobilepatrol.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.adapter.EditListAdapter;

/**
 * Created by shjshi on 2018/1/15.
 */

public class TextActivity extends BaseActivity{
        private String[] mData = {"我们说好的", "一辈子的孤单", "不在联系", "那又如何", "如果爱下去", "你的样子", "或者", "悟空", "默", "陪你度过漫长岁月", "没离开过", "花房姑娘", "一无所有", "She‘gone", "相爱一场", "当我们"};
        private ListView mListView;
        private EditListAdapter mAdapter;
        private Button mAddBtn;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mAddBtn = (Button) findViewById(R.id.add_btn);
            mListView = (ListView) findViewById(R.id.edit_lv);
            mAdapter = new EditListAdapter();
            mListView.setAdapter(mAdapter);
            mAdapter.setData(iniData());

            mAddBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mAdapter.addItem();
                }
            });

        }

        private List<EditListAdapter.SongBean> iniData() {
            List<EditListAdapter.SongBean> list = new ArrayList<>();
            for (int i = 0; i < mData.length; i++) {
                EditListAdapter.SongBean bean = new EditListAdapter.SongBean();
                bean.setNum(0);
                list.add(bean);
            }
            return list;
        }

    @Override
    protected int attachLayoutRes() {
        return R.layout.test3;
    }

    @Override
    public void setListener() {

    }
}
